//
//  UIImageView+WebImage.swift
//  新浪微博
//
//  Created by Jack.Lin on 16/7/6.
//  Copyright © 2016年 Jack.Lin. All rights reserved.
//

import SDWebImage

extension UIImageView {
   
    // 隔离 SDWebImage
    func cz_setIamge(urlString: String?, placeholderImage: UIImage?, isAvatar: Bool = false) {
    
        guard let urlString = urlString,
            url = URL(string: urlString) else {
                
                image = placeholderImage
                
                return
        }
    
        sd_setImage(with: url, placeholderImage: placeholderImage, options: [], progress: nil) { [weak self] (image, _, _, _) in
          
            if isAvatar {
             
                self?.image = image?.cz_avatarImage(size: self?.bounds.size)
            }
            
        }
    }
    
    
}
